#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import random

# task1
# A monkey have a number of peaches
# every time it eat half and one
# after 10th day, all the peaches run out


def count_peaches():
    count = 0
    for i in range(10):
        count = (count + 1) * 2
    return count


# task2
# Ynahui triangel row:n , field: m
# row n --> n - 1
# column m --> m - 1
# C(n, m) = n!/[m!(n-m)!]


def factorial(n):
    if n == 1 or n == 0:
        return 1
    return factorial(n - 1) * n


def yanghui_calculate(row, column):
    row -= 1
    column -= 1
    value = factorial(row) // (factorial(column) * factorial(row - column))
    return value


# print(yanghui_calculate(5, 2))

# task3
# generate 10 random number
# count every letter exist times


def count_times():
    letters = []
    statistic = {}
    one_time = []
    over_one_time = []
    for _ in range(10):
        letters.append(random.randrange(1, 20))
    for k in letters:
        statistic[k] = statistic.get(k, 0) + 1
    for k, v in statistic.items():
        if v == 1:
            one_time.append(k)
        else:
            over_one_time.append(k)
    return one_time, over_one_time
